package com.bins.langchain.easy.rag.controller;

import com.bins.langchain.easy.rag.service.RagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/rag")
@RestController
public class ChatController {

    @Autowired
    private RagService ragService;

    @PostMapping("/load")
    public ResponseEntity load() {
        ragService.loadDocument();
        return ResponseEntity.ok("success");
    }

    @GetMapping("/chat")
    public String chat(String prompt) {
        return ragService.chat(prompt);
    }
}